<?php get_header(); ?>
<?php
/*
Template Name: Product List
*/
?>	
<div id="colLeft">
<?

$taxonomyname = 'nhom-san-pham';
//$args = array()
$toplevelterms = get_terms($taxonomyname,'parent=0');//, 'hide_empty=0');
$termchildren = array();
foreach ($toplevelterms as $toplevelterm) {
    $termchildren[] = $toplevelterm->term_id;
}
$nhom_arr = array();
foreach ($termchildren as $child)
{
    $term = get_term_by('id', $child, $taxonomyname);
	$t_id = $term->term_id;
	$term_meta = get_option( "taxonomy_$t_id" );
    $nhom_arr[] = array('image' => $term_meta['nhomsp_image'],
						'link' => get_term_link($term->name, $taxonomyname),
						'name' => $term->name);
	
}
$temp = 0;
//print_r($term);

?>
<table id="product_list" cellpadding="0">
	<tr>	
 	<?php
	 for($i = 0; $i< count($nhom_arr); $i++)
	 {
	?>
   
    	<td class="td_hover"><div class="product_detail">
        		<a href="<?= $nhom_arr[$i]['link']; ?>" title="<?= $nhom_arr[$i]['name']; ?>" >
                <img src="<?php bloginfo('url'); ?>/<? if($nhom_arr[$i]['image'] != '') echo $nhom_arr[$i]['image']; else echo 'images/no_image.jpg'; ?>" alt="<?= $nhom_arr[$i]['name']; ?>" title="<?= $nhom_arr[$i]['name']; ?>" />
                </a>
                <p><a href="<?= $nhom_arr[$i]['link']; ?>" title="<?= $nhom_arr[$i]['name']; ?>" ><?= $nhom_arr[$i]['name']; ?></a></p>
            </div>
        </td>
     <?
    	
		if(($i-3) % 4 == 0){
	?>
		</tr>
        <tr><td colspan="7" class="space_row"></td></tr>
		<tr>
  
    <?php
		}
		else
		{
			?>
            	<td class="space_col"></td>
            <?
		}
	 }
	?>
  </tr>  
</table>
</div>

<?php get_sidebar(); ?> 

<?php get_footer(); ?>